function vel = position_s_traj_vel(a_value,t_acc,t_ed,t)
%     if(a_value<0 || t_ed <2*t_acc)
%         vel = 0;
%     else    
%         if(t>=0 && t < t_acc)
%             vel = a_value*t;
%         elseif(t>= t_ed-t_acc && t<t_ed)
%             vel = a_value*(t_ed-t);
%         elseif(t_acc<= t && t< t_ed-t_acc)
%             vel = t_acc*a_value;
%         else
%             vel = 0;
%         end
%     end




    vel = 0.*(a_value<0 | t_ed <2*t_acc |t<0 | t>= t_ed)+ t*a_value.*(t>=0 & t < t_acc)+ a_value*t_acc.*(t_acc<= t & t< t_ed-t_acc)+a_value*(t_ed-t).*(t>= t_ed-t_acc & t<t_ed);
end